<!-- 店铺主页 -->
<template>
    <div class="cp-container">
        <shop-banner :is-editor="isEditor" :shop-info="shopInfo"></shop-banner>
        <case-list :is-editor="isEditor" :shop-id="shopId"></case-list>
        <shop-evaluate :shop-id="shopId"></shop-evaluate>
    </div>
</template>

<script lang="ts">
import {
    Vue,
    Component,
    Prop,
    Watch
} from 'nuxt-property-decorator'
import shopBanner from './bannner.vue'
import caseList from './caseList.vue'
import shopEvaluate from './evaluate.vue'
@Component({
    name: 'shopIndex',
    components: {
        shopBanner,
        caseList,
        shopEvaluate
    }
})
export default class ShopIndex extends Vue {
    shopInfo: any = {}
    shopId: number | string = ''
    @Prop({
        type: Boolean,
        default: false
    })
    isEditor!: boolean
    @Watch('$store.state.shopInfo.data.id', {immediate: true, deep: true})
    init (nv: number | string) {
        if (nv) {
            const shopInfo = this.$store.state.shopInfo.data
            this.shopInfo = shopInfo
            this.shopId = Number(shopInfo.id)
        }
    }
    created () {
        if (!this.isEditor) {
            this.shopId = Number(this.$route.params.id)
        }
    }
}
</script>
